import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import {createSvgIconsPlugin} from "vite-plugin-svg-icons";
import path from "path";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [
    vue(),
    createSvgIconsPlugin({
      iconDirs: [path.resolve(process.cwd(), 'src/icons')],
      symbolId: 'icon-[name]'
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    }
  },
  esbuild:{
    drop: ['console','debugger'], // 删除 所有的console 和 debugger
  },
  server: {
    port: 3000,
    proxy: {
      '/api': {
        target: 'https://mock.apifox.cn/m1/2674551-0-default/',
        changeOrigin: true,
        rewrite: (path) => path.replace(/^\//, '') // 不可以省略rewrite
      }
    }
  }
})
